1. Field of the Invention
The present invention relates to data processing field, particularly to the multi-tenancy technology, and more particularly to a multi-tenancy data storage and access method and apparatus.
2. Description of the Related Art
The multi-tenancy technology refers a single instance of software that runs on a service provider's server and provides service to many client organizations (i.e., tenants), especially small and medium-sized enterprises (SMEs). FIG. 1 is an exemplary schematic illustration of the architecture of a multi-tenancy application. In a scenario of a large-scale multi-tenancy application, there may be many (e.g., over 1 million) SME tenants accessing the application instance on a hosting platform at the same time. With the large increase of the number of tenants, a multi-tenancy application will face the following challenges: the first is to keep a relatively low and stable resource use costs per tenant, and at the same time to keep an acceptable performance level per tenant; the second is to keep a relatively low management complexity, such as in cross-tenant operations, tenant registration, etc. The current typical multi-tenancy technology uses at least one of three physical data storage or sharing modes as illustrated in FIG. 2.
The first is a separate database mode, in which each tenant owns a separate database. This mode has a number of disadvantages. Taking a current primary relational database system as an example, building a new database each time requires about 80M default disk space. As such, if 300 databases are required, 24 G disk space will be needed; if 500 databases are required, 40 G disk space will be needed. Further, during runtime, a database will consume a relatively large memory space. For example, 300 database themselves need at least 2.4 G memory space, and 500 databases need at least 3 G memory space. Additionally, with the increase of the number of tenants, the overall system database access performance level may decrease dramatically. Due to the above disadvantages, such separate database mode is only practically applicable to scenarios where the number of tenants is small and the tenants are large-scale ones.
The second mode is a shared database and shared table mode, in which all tenants share a same table set (that is, a set of tables for a specific application) in a same database. As such, a new field “Tenant ID” needs to be added to each table in the table set in order to distinguish between data of different tenants. The advantages of such a mode include: (i) it is easy to perform cross-tenant management operations since there is only one table set; (ii) to build a database only needs about 80M disk space by default; (iii) during runtime, the database itself consumes about 600-700M memory space by default. However, the disadvantage of such a mode is that with the number of tenants increasing to a very large number (e.g., over 1000), there will occur a break point where multi-tenancy data will interfere severely with each other, and the overall system data access performance decreases dramatically.
The third mode is a shared database and separate table mode in which all tenants share a same database with each tenant owning its separate table set. The advantages of such a mode is that, even with the number of tenants increasing to a very large number, there will not occur a break point where the overall system data access performance decreases dramatically. To build a database only about 80M disk space is needed by default and during runtime the database itself consumes about 600-700M memory space by default. The disadvantage of such a mode, however, is that, since the number of table sets is equal to the number of tenants, with the number of tenants increasing, the number of table sets will become very large. As such, cross-tenant management operations, such as tenant registration, will become extremely complex.
FIG. 3 illustrates the overall system data access performance of an exemplary multi-tenancy application varying with the increase of the number of tenants under the three modes. As shown, the performance under the shared database and separate table mode is relatively high and stable with the increase of the number of tenants. The performance under the shared database and shared table mode is lower and, with the number of tenants increasing to about 1000, there will occur a break point where the overall system data access performance decreases dramatically. The overall system data access performance under the separate database mode will decrease dramatically with the increase of the number of tenants.
Accordingly, there is a need for a multi-tenancy data storage solution which can both keep the overall system data access performance stable with the large increase of the number of tenants and, at the same time, maintain low management costs.